/**     
 * @Title: SwaggerConfig.java   
 * @Package me.springboot.springfox.common   
 * @Description: TODO
 * @author weiwei 
 * @date 2017年8月11日 下午3:58:38   
 * @version V1.0     
 */
package me.springboot.springfox.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.common.base.Predicate;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ClassName: SwaggerConfig
 * @Description: TODO
 * @author weiwei
 * @date 2017年8月11日 下午3:58:38
 * 
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

	@Bean
	public Docket adminApi() {
		return new Docket(DocumentationType.SWAGGER_2).groupName("API").forCodeGeneration(true).pathMapping("/").select().paths(paths()).build().apiInfo(apiInfo())
				.useDefaultResponseMessages(false);
	}

	private ApiInfo apiInfo() {
		Contact contact = new Contact("weiwei", "https://gitee.com/xaoyaoyao", "xaoyaoyao@aliyun.com");
		return new ApiInfoBuilder().title("Document Api").description("Springboot-Springfox Example").license("Apache License Version 2.0").contact(contact).version("2.0")
				.build();
	}

	private Predicate<String> paths() {
		return PathSelectors.regex("^/(?!error).*$");
	}
}
